package com.misakyanls.examples;

import java.io.PrintStream;

public class Palindrom {
	public static void main(String[] args) {
		PrintStream os = System.out;

		String inputPalindrom = args[0];
		if (!isPalindrom(inputPalindrom)) {
			os.println(inputPalindrom);
			return;
		}

		if (consistsOfOnly(inputPalindrom, inputPalindrom.charAt(0))) {
			os.println("NO SOLUTION");
			return;
		} else
			os.println(inputPalindrom.substring(0, inputPalindrom.length() - 1));

	}

	private static String reverseString(String s) {
		char[] str = s.toCharArray();
		int len = str.length - 1;
		for (int i = 0; i <= len / 2; i++) {
			char c = str[i];
			str[i] = str[len - i];
			str[len - i] = c;
		}
		return new String(str);
	}

	private static boolean isPalindrom(String s) {
		return s.equalsIgnoreCase(reverseString(s));
	}

	private static boolean consistsOfOnly(String s, char c) {
		for (int i = 0; i < s.length(); i++) {
			if (s.charAt(i) != c)
				return false;
		}
		return true;
	}

}
